package com.dpc.springbootknife4j.controller;

import com.dpc.springbootknife4j.entity.AddressVo;
import com.dpc.springbootknife4j.entity.UserParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Api("User Controller")
public class UserController {

    /**
     * http://localhost:8080/user/add .
     *
     * @param userParam user param
     * @return user
     */
    @ApiOperation("Add User")
    @PostMapping("/add")
    public ResponseEntity<String> add(@RequestBody UserParam userParam) {
        System.out.println(userParam);
        return ResponseEntity.ok("success");
    }


    /**
     * http://localhost:8080/address/add .
     *
     * @param addressParam param
     * @return address
     */
    @ApiOperation("get Address")
    @PostMapping("/get")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "city", type = "query", dataTypeClass = String.class, required = true),
            @ApiImplicitParam(name = "zipcode", type = "query", dataTypeClass = String.class, required = true)
    })
    public ResponseEntity<String> add(AddressVo addressParam) {
        System.out.println(addressParam.toString());
        return ResponseEntity.ok("success");
    }

}
